﻿$(document).ready(function () {
    //保存按钮响应函数
    $("#btnPropagateSave").bind("click", PropagateSave);

});
function PropagateSave() {
    var type = $("#PropagateID").val() == "" ? "AddPropagate" : "EditPropagate";
    var count = $.trim($("#SymbolTitle").html());
    art.dialog({
        title: '系统提示',
        content: "将要" + (type == "AddPropagate" ? "增加" : "编辑") + "海报 [" + count + "]。\n确定操作吗？",
        lock: true,
        ok: function () {
            this.close();
            doAjax("../",
           type,
           {
               "PropagateID": $("#PropagateID").val(),
               "SymbolID":$("#SymbolID").val(),
               "PropagateDetail": HTMLEncode($("#txtPropagateDetail").val())
           },
           "json",
           function (json) {

               switch (json) {

                   case 0:
                       art.dialog.alert("系统异常，未保存数据，请再次点击保存！");
                       break;
                   default:
                       art.dialog
                            ({
                                time: 0.5,
                                content: '保存成功！',
                                close: function () { location.href = "../MicroWebsite/SymbolShow.aspx?PID=123"; },
                                lock: true
                            });
                       break;
               }
           });
        },
        cancelVal: '取消',
        cancel: true
    });
}
function HTMLEncode(html) {
    var temp = document.createElement("div");
    (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
    var output = temp.innerHTML;
    temp = null;
    return output;
}